package com.ycy;

import org.redisson.Redisson;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

public class ClusterDemo {

  public static void main(String[] args) {
    Config config = new Config();
    config.useClusterServers()
            .setScanInterval(2000) // cluster state scan interval in milliseconds
            .addNodeAddress("redis://192.168.156.111:8001", "redis://192.168.156.111:8002")
            .addNodeAddress("redis://192.168.156.111:8003");
    RedissonClient redissonClient = Redisson.create(config);

    String key = "student";
    RMap<Object, Object> student = redissonClient.getMap(key);
    student.put("age","23");
    student.put("name","小明");

    RMap<Object, Object> map = redissonClient.getMap(key);
    System.out.println(map.get("name"));

  }

}
